package 蓝桥真题;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class 寻找2020 {
       static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
       final static int N=310;
       static char[][]g=new char[N][N];
       static int n=300;
       public static void main(String[] args) throws IOException {
    	      for(int i=0;i<n;i++){
    	    	  br.read(g[i],0,n);
    	    	  br.readLine();
    	      }
    	      int res=0;
    	      for(int i=0;i<n;i++)
    	    	  for(int j=0;j<n;j++){
    	    		  if(g[i][j]=='2'){
    	    			  String t="2";
    	    			  for(int y=1;y<=3;y++){
    	    				  int b=j+y;
        	    			  if(b<n)t+=g[i][b];
        	    		  } 
    	    			  if("2020".equals(t))res++;
    	    			  t="2";
    	    			  for(int x=1;x<=3;x++){
    	    				  int a=i+x;
        	    			  if(a<n)t+=g[a][j];
        	    		  } 
    	    			  if("2020".equals(t))res++;
    	    			  t="2";
    	    			  for(int xy=1;xy<=3;xy++){
    	    				  int a=i+xy;int b=j+xy;
        	    			  if(a<n&&b<n)t+=g[a][b];
        	    		  } 
    	    			  if("2020".equals(t))res++;
    	    		  }
    	    	  }
    	      System.out.print(res);
	}
}
